package ru.hh.team02.chat.client;

import java.net.Socket;
import java.util.Scanner;

public class ClientWriter implements Runnable {
	private final static int CLIENT_PORT = 5555;
	
	private StringSocket socket;
	
	public static void main(String[] args) {
		new ClientWriter().run();
	}
	
	@Override
	public void run() {
	    Scanner scanner = new Scanner(System.in);
		try {
		    socket = new StringSocket(new Socket("localhost", CLIENT_PORT));
			String input = "";
			do {
				input = scanner.nextLine();
				socket.write(input);
			} while (!input.equals("exit"));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
		    scanner.close();
		    socket.close();
		}
	}
}
